################
#PSRM: Explaining Support for Redistribution: Social Insurance Systems and Fairness
#
#Observational Analysis ESS
#Figure A 1
#
#Verena Fetscher
#July 2022
####################


####################
# Load data
####################
source("dataframes.R")


##########################
#Produces Figure A.1: Distribution of income distance.
##########################

ggplot(data_list, aes(x=income.dist.th)) + 
  geom_density(kernel="gaussian",bw=14,color="blue") + 
  geom_density(data = data_imputed, aes(x=income.dist.th), 
               colour = "red",kernel="gaussian",bw=14) +
  xlab("Income distance (in 1,000s PPP USD)")+ 
  ylab("Density")+
  facet_wrap(~country)+
  coord_cartesian(xlim=c(-75,125),ylim = c(0,.0225))+
  theme_bw()+
  theme(panel.border=element_blank(),axis.line=element_line(),
        legend.position="bottom",legend.text = element_text(size = 14),
        legend.title = element_text(size=14),axis.text=element_text(size=12),
        axis.title=element_text(size=14),strip.background =element_rect(fill=F,colour = "white"))


##########################
#Save figure
##########################

ggsave(file="figure_a1.pdf", height = 5.83, width = 8.27, units = "in")

